from rest_framework.serializers import ModelSerializer

from .models import *
from stock.models import Goods, Warehouse

class GoodsSerializer(ModelSerializer):
    class Meta:
        model = Goods
        fields = ['goods_id','num','name','kind','retail']

class WarehouseSerializer(ModelSerializer):
    class Meta:
        model = Warehouse
        fields = ['ware_id','name','address']

class EnterSerializer(ModelSerializer):
    goods = GoodsSerializer(many=False)
    ware = WarehouseSerializer(many=False)
    class Meta:
        model = Enter
        fields = ['enter_id','num','goods','count','ware','type','enter_time','staff_name','staff_num']


class OutboundSerializer(ModelSerializer):
    goods = GoodsSerializer(many=False)
    ware = WarehouseSerializer(many=False)
    class Meta:
        model = Outbound
        fields = ['out_id','num','goods','count','ware','type','out_time','staff_name','staff_num']

class TransportSerializer(ModelSerializer):
    goods = GoodsSerializer(many=False)
    class Meta:
        model = Transport
        fields = ['transport_id','num','goods','count','company','transport_time','staff_name','staff_num','signer','sign_time','address']

class BillsSerializer(ModelSerializer):
    class Meta:
        model = Bills
        fields = ['bills_id','num','type','bills_time','staff_name','staff_num']